package cn.mazexal.examapi.common.models;

import cn.mazexal.examapi.models.vo.ExamQuestionMaterialsVO;
import lombok.Data;

import java.util.Collections;
import java.util.List;

/**
 * @author: Mazexal
 * Date: 2025/5/25
 */
@Data
public class PagedQuestionResponse<T> extends PagedResponse{

    private List<ExamQuestionMaterialsVO> materialsList;

    public List<ExamQuestionMaterialsVO> getMaterialsList() {
        if(materialsList == null){
            return Collections.emptyList();
        }else{
            return materialsList;
        }
    }

    public static <T> PagedQuestionResponse<T> of(PagedQuestionData<T> pagedData) {
        PagedQuestionResponse<T> response = new PagedQuestionResponse();
        response.setSuccess(true);
        response.setData(pagedData.getData());
        response.setTotal(pagedData.getTotal());
        response.setPageSize(pagedData.getPageSize());
        response.setCurrent(pagedData.getCurrent());
        response.setMaterialsList(pagedData.getMaterialsList());
        return response;
    }
}
